<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('修改商品')" />
	<th:block th:include="include :: bootstrap-fileinput-css" />
	<th:block th:include="include :: select2-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
     <div class="row">            
            <div class="col-sm-12">
                <div class="ibox float-e-margins">                    
                    <div class="ibox-content">                    	                       
                        <div class="form-group">
                        <h4 class="form-header h4">商品图片</h4>                     
	                        <div class="file-loading">
					            <input  type="hidden" id="previewListEdit" th:value="${previewListEdit}"/>
					            <input name="file" id="fileinput-demo-1" type="file" multiple>
					        </div>
                        </div>
                        <hr>                        
                    </div>
                </div>
            </div>
        </div>
        <form class="form-horizontal m" id="form-goods-edit" th:object="${goods}">
            <input id="id" name="id" th:field="*{id}"  type="hidden">
           
        <h4 class="form-header h4">商品详情</h4> 
        	<div class="form-group">	
				<label class="col-sm-2 control-label">商品名称：</label>
				<div class="col-sm-3">
					<input id="goodsName" name="goodsName" th:field="*{goodsName}" class="form-control" type="text">
				</div>
			
				<label class="col-sm-2 control-label">商品编号：</label>
				<div class="col-sm-3">
					<input id="goodsBh" name="goodsBh" th:field="*{goodsBh}" class="form-control" type="text">
				</div>
			</div>
			
			<div class="form-group">	
				<!-- <label class="col-sm-2 control-label">商品图片：</label>
				<div class="col-sm-3">
					<input id="goodsTp" name="goodsTp" th:field="*{goodsTp}" class="form-control" type="text">
				</div> -->
				<label class="col-sm-2 control-label">销量：</label>
				<div class="col-sm-3">
					<input id="goodsXl" name="goodsXl" th:field="*{goodsXl}" class="form-control" type="text">
				</div>
				<label class="col-sm-2 control-label">库存：</label>
				<div class="col-sm-3">
					<input id="goodsNum" name="goodsNum" th:field="*{goodsNum}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-2 control-label">商品类型：</label>
				<div class="col-sm-3">
					<div class="input-group" style="width: 100%">
						<select id="goodsLxId" name="goodsLxId" class="form-control m-b">
							<option></option>
							<option th:each="goodsLx:${goodsLxList}"
								th:value="${goodsLx.id}"
								th:text="${goodsLx.goodsLxName}" th:field="*{goodsLxId}"></option>
						</select>
					</div>
				</div>
				
				<label class="col-sm-2 control-label">商品状态：</label>
				<div class="col-sm-3">
					<select id="goodsStatus" name="goodsStatus" class="form-control m-b" th:field="*{goodsStatus}">
						<option value="上架">上架</option>
						<option value="下架">下架</option>						
					</select>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-2 control-label">现价：</label>
				<div class="col-sm-3">
					<input id="goodsNowprice" name="goodsNowprice" th:field="*{goodsNowprice}" class="form-control" type="text">
				</div>
				
				<label class="col-sm-2 control-label">原价：</label>
				<div class="col-sm-3">
					<input id="goodsBeforeprice" name="goodsBeforeprice" th:field="*{goodsBeforeprice}" class="form-control" type="text">
				</div>
			</div>
			
			<div class="form-group">	
				<label class="col-sm-2 control-label">运费：</label>
				<div class="col-sm-3">
					<input id="goodsReceiveprice" name="goodsReceiveprice" th:field="*{goodsReceiveprice}" class="form-control" type="text">
				</div>
				
				<label class="col-sm-2 control-label">重量：</label>
				<div class="col-sm-3">
					<input id="goodsWeight" name="goodsWeight" th:field="*{goodsWeight}" class="form-control" type="text">
				</div>
			</div>
			
			<div class="form-group">	
				<label class="col-sm-2 control-label">商品副文本：</label>
				<div class="col-sm-8">
					<textarea id="goodsIntroduce" name="goodsIntroduce" th:field="*{goodsIntroduce}" class="form-control"></textarea>
				</div>
			</div>
			
			
			
			
			<h4 class="form-header h4">商品属性</h4>
			<div class="form-group">	
				<label class="col-sm-2 control-label">是否新品：</label>
				
				<div class="col-sm-3">
					<select id="goodsIsnew" name="goodsIsnew" class="form-control m-b" th:field="*{goodsIsnew}">
						<option value="新品">新品</option>
						<option value="非新品">非新品</option>						
					</select>
				</div>
				
				<label class="col-sm-2 control-label">是否参与活动：</label>
				
				<div class="col-sm-3">
					<select id="goodsIsjoin" name="goodsIsjoin" class="form-control m-b" th:field="*{goodsIsjoin}">
						<option value="参与活动">参与活动</option>
						<option value="不参与活动">不参与活动</option>						
					</select>
				</div>
			</div>
			
			<div class="form-group">	
				<label class="col-sm-2 control-label">是否包邮：</label>								
				<div class="col-sm-3">
					<select id="goodsEmail" name="goodsEmail" class="form-control m-b" th:field="*{goodsEmail}">
						<option value="包邮">包邮</option>
						<option value="不包邮">不包邮</option>						
					</select>
				</div>
				
				<label class="col-sm-2 control-label">是否支持货到付款：</label>				
				<div class="col-sm-3">
					<select id="goodsMoneyaftergive" name="goodsMoneyaftergive" class="form-control m-b" th:field="*{goodsMoneyaftergive}">
						<option value="支持货到付款">支持货到付款</option>
						<option value="不支持货到付款">不支持货到付款</option>						
					</select>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-2 control-label">有无正品保证：</label>				
				<div class="col-sm-3">
					<select id="goodsRealpromise" name="goodsRealpromise" class="form-control m-b" th:field="*{goodsRealpromise}">
						<option value="正品保证">正品保证</option>
						<option value="无正品保证">无正品保证</option>						
					</select>
				</div>
				
				<label class="col-sm-2 control-label">是否七天无理由退货：</label>
				
				<div class="col-sm-3">
					<select id="goodsBack" name="goodsBack" class="form-control m-b" th:field="*{goodsBack}">
						<option value="七天无理由退货">七天无理由退货</option>
						<option value="不支持七天无理由退货">不支持七天无理由退货</option>						
					</select>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-2 control-label">有无发票：</label>			
				<div class="col-sm-3">
					<select id="goodsInvoice" name="goodsInvoice" class="form-control m-b" th:field="*{goodsInvoice}">
						<option value="有发票">有发票</option>
						<option value="无发票">无发票</option>						
					</select>
				</div>
			
				<label class="col-sm-2 control-label">是否保修：</label>
				
				<div class="col-sm-3">
					<select id="goodsRepair" name="goodsRepair" class="form-control m-b" th:field="*{goodsRepair}">
						<option value="保修">保修</option>
						<option value="不保修">不保修</option>						
					</select>
				</div>
			</div>
			
			<div class="form-group">	
				<label class="col-sm-2 control-label">库存类型：</label>			
				<div class="col-sm-3">
					<select id="goodsStocktype" name="goodsStocktype" class="form-control m-b" th:field="*{goodsStocktype}">
						<option value="显示库存">显示库存</option>
						<option value="不显示库存">不显示库存</option>	
						<option value="拍下减库存">拍下减库存</option>
						<option value="付款减库存">付款减库存</option>
						<option value="永不减库存">永不减库存</option>					
					</select>
				</div>
				
				<label class="col-sm-2 control-label">商品布局：</label>				
				<div class="col-sm-3">
					<select id="goodsLayout" name="goodsLayout" class="form-control m-b" th:field="*{goodsLayout}">
						<option value="出售中">出售中</option>
						<option value="审核中">审核中</option>	
						<option value="已售罄">已售罄</option>	
						<option value="仓库中">仓库中</option>	
						<option value="回收站">回收站</option>						
					</select>
				</div>
			</div>
			
			<div class="form-group">	
				<label class="col-sm-2 control-label">商品概念：</label>					
				<div class="col-sm-3">
					<select id="goodsYuliu1" name="goodsYuliu1" class="form-control m-b" th:field="*{goodsYuliu1}">					
						<option value="现实物品">现实物品</option>	
						<option value="虚拟物品">虚拟物品</option>										
					</select>
				</div>							
			</div>
			
		</form>
    </div>
    <div th:include="include::footer"></div>
    <th:block th:include="include :: bootstrap-fileinput-js" />
    <th:block th:include="include :: select2-js" />
    <script type="text/javascript">
		var prefix = ctx + "Goods/goods";
		$("#form-goods-edit").validate({
			rules:{
				xxxx:{
					required:true,
				},
			},
			focusCleanup: true
		});
		
		function submitHandler() {
	        if ($.validate.form()) {
	        	$(".fileinput-upload-button").click();
	            $.operate.save(prefix + "/edit", $('#form-goods-edit').serialize());
	        }
	    }
		
		var initialPreview = [];
	    var initialPreviewConfig = [];
	    var str= document.getElementById("previewListEdit").value;
	    var previewListEdit = eval("(" + str + ")");
	    var goods_id=document.getElementById("id").value;
	   
	     
	        
	      

	    $(document).ready(function () {
	    	for (var i = 0; i < previewListEdit.length; i++) {
	            initialPreview.push(previewListEdit[i].url);
	            var config = {caption: previewListEdit[i].fileName, filename: previewListEdit[i].fileName, downloadUrl:  previewListEdit[i].url, key:previewListEdit[i].key}
	            initialPreviewConfig.push(config);
	        }
	    	$("#fileinput-demo-1").fileinput({
	            'theme': 'explorer-fas',
	            'uploadUrl': prefix + "/upload/" + goods_id,
	            allowedFileExtensions: ['xls', 'xlsx', 'doc', 'docx', 'pdf', 'ppt', 'pptx', 'png', 'jpg'],//允许接收的文件后缀
	            uploadAsync: false,  //默认异步上传
	            showUpload: false,  //是否显示上传按钮
	            showPreview : true, //是否显示预览
	            showCaption: true, //是否显示标题
	            showClose: true,    //是否显示关闭按钮
	            removeClass: "btn btn-danger",
	            enctype: 'multipart/form-data',
	            maxFileCount:10,
	            validateInitialCount:true,
	            initialPreview: initialPreview,
	            initialPreviewAsData: true,
	            initialPreviewFileType: 'image',// 文件类型: 图片为images 其他为object
	            initialPreviewConfig: initialPreviewConfig,
	            deleteUrl: prefix + "/deleteSave/",// 当初始化图片加载后点击删除图片会根据此url发起请求 参数为key
	            overwriteInitial: false,
	            previewFileIcon: '<i class="glyphicon glyphicon-file"></i>',
	            previewFileIconSettings: {
	                'docx': '<i ass="fa fa-file-word-o text-success"></i>',
	                'doc': '<i ass="fa fa-file-word-o text-success"></i>',
	                'xlsx': '<i class="fa fa-file-excel-o text-success"></i>',
	                'xls': '<i class="fa fa-file-excel-o text-success"></i>',
	                'pptx': '<i class="fa fa-file-powerpoint-o text-success"></i>',
	                'ppt': '<i class="fa fa-file-powerpoint-o text-success"></i>',
	                'jpg': '<i class="fa fa-file-photo-o text-success"></i>',
	                'pdf': '<i class="fa fa-file-archive-o text-success"></i>',
	            }           
	        });
	    });
	</script>
</body>
</html>
